﻿<UserControl x:Class="Avivo.Tools.Sprite.Views.SpriteView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:s="clr-namespace:Avivo.Tools.Sprite"
	xmlns:v="clr-namespace:Avivo.Tools.Sprite.Views"
	xmlns:m="clr-namespace:Avivo.Tools.Sprite.Models"
	xmlns:avalon="http://icsharpcode.net/sharpdevelop/avalonedit">
	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="../Resources/ExpressionTheme.xaml" />
				<ResourceDictionary Source="../Resources/Styles.xaml" />
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>
	<UserControl.DataContext>
		<m:SpriteViewModel />
	</UserControl.DataContext>
	<Grid x:Name="LayoutRoot">
		
		<!--<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Hidden">-->

		<StackPanel Orientation="Vertical" Margin="5" MinWidth="320">
			<!-- Instructions -->
			<Border Background="#595959" CornerRadius="0,3,3,3" Margin="0,0,0,2">
				<StackPanel Orientation="Vertical" Margin="6">
					<TextBlock Foreground="White">
						<Run>Generate sprites from xaml templates. Visit </Run>
						<Hyperlink NavigateUri="http://xbsprite.codeplex.com" Command="{Binding HyperlinkCommand}" CommandParameter="http://xbsprite.codeplex.com">http://xbsprite.codeplex.com</Hyperlink>
					</TextBlock>
				</StackPanel>
			</Border>
			
			<!-- Sprites -->
			<Border Background="#595959" CornerRadius="3" Margin="0,0,0,2">
				<StackPanel Margin="4">
					<TextBlock Text="Sprites" Style="{DynamicResource HeaderTextStyle}" />
					
					<!-- Grid header -->
					<Grid Margin="0,3,0,0">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="15" />
							<ColumnDefinition Width="1*" />
							<ColumnDefinition Width="3*" />
							<ColumnDefinition Width="1*" />
							<ColumnDefinition Width="50" />
						</Grid.ColumnDefinitions>

						<Grid Grid.Column="1" Margin="5,0,0,0">
							<TextBlock Text="Class" Foreground="White" />
						</Grid>

						<Grid Grid.Column="2" Margin="5,0,0,0">
							<TextBlock Text="Text" Foreground="White" />
						</Grid>

						<Grid Grid.Column="3" Margin="2,0,0,0">
							<TextBlock Text="Template" Foreground="White" />
						</Grid>
					</Grid>
					
					<!-- Grid items -->
					<ItemsControl Margin="0,2,0,0" ItemsSource="{Binding Sprites}">
						<ItemsControl.ItemsPanel>
							<ItemsPanelTemplate>
								<StackPanel Orientation="Vertical" />
							</ItemsPanelTemplate>
						</ItemsControl.ItemsPanel>
						<ItemsControl.ItemTemplate>
							<DataTemplate>
								<Grid>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="15" />
										<ColumnDefinition Width="1*" />
										<ColumnDefinition Width="3*" />
										<ColumnDefinition Width="1*" />
										<ColumnDefinition Width="Auto" />
										<ColumnDefinition Width="Auto" />
									</Grid.ColumnDefinitions>

									<Grid Grid.Column="0" Margin="0,1,0,2">
										<TextBlock Text="{Binding Index}" TextAlignment="Right" Foreground="#AAAAAA" FontWeight="Bold" VerticalAlignment="Center" />
									</Grid>

									<Grid Grid.Column="1" Margin="4,1,0,2">
										<TextBox TabIndex="10" Text="{Binding Name, Mode=TwoWay}" VerticalAlignment="Center" />
									</Grid>

									<Grid Grid.Column="2" Margin="4,1,0,2">
										<TextBox TabIndex="11" Text="{Binding Content, Mode=TwoWay}" VerticalAlignment="Center" />
									</Grid>

									<Grid Grid.Column="3" Margin="4,1,0,2">
										<!--<TextBox Text="{Binding Template, Mode=TwoWay}" />-->
										<ComboBox TabIndex="12" ItemsSource="{Binding TemplateList}" SelectedItem="{Binding Template, Mode=TwoWay}" VerticalAlignment="Center" />
									</Grid>

									<Grid Grid.Column="4" Margin="4,1,0,2">
										<Button TabIndex="13" Command="{Binding AddSpriteCommand}" Padding="5,2,5,2" Cursor="Hand">
											<Path Data="M0,1 L2,1 M1,0 L1,2" Stroke="Lime" StrokeThickness="2" Stretch="Fill" Width="10" Height="10" />
										</Button>
									</Grid>

									<Grid Grid.Column="5" Margin="4,1,0,2">
										<Button TabIndex="14" Command="{Binding RemoveSpriteCommand}" Padding="5,2,5,2" Cursor="Hand">
											<Path Data="M0,1 L2,1" Stroke="Red" StrokeThickness="2" Stretch="Fill" Width="10" Height="10" />
										</Button>
									</Grid>
								</Grid>
							</DataTemplate>
						</ItemsControl.ItemTemplate>
					</ItemsControl>
				</StackPanel>
			</Border>

			<!-- Properties -->
			<Border Background="#595959" CornerRadius="3" Margin="0,0,0,2">
				<StackPanel Margin="4">
					<TextBlock Text="Properties" Style="{DynamicResource HeaderTextStyle}" />
					<Grid>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="65" />
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="Auto" />
						</Grid.ColumnDefinitions>

						<TextBlock Grid.Row="0" Grid.Column="0" Text="Class name" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
						<TextBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" TabIndex="20" Text="{Binding BaseClassName, Mode=TwoWay}" Margin="0,2,0,2" VerticalAlignment="Center" s:TextBoxInstantBinding.IsEnabled="True" />
						
						<TextBlock Grid.Row="1" Grid.Column="0" Text="Input dir" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
						<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding InputDirectory, Mode=TwoWay}" TabIndex="21" Margin="0,2,0,2" VerticalAlignment="Center" />
						<Button Grid.Row="1" Grid.Column="2" Content="..." TabIndex="22" Command="{Binding InputBrowseCommand}" Padding="5,2,5,2" Margin="5,2,0,2" HorizontalAlignment="Left" VerticalAlignment="Center" />

						<TextBlock Grid.Row="2" Grid.Column="0" Text="Output dir" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
						<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding OutputDirectory, Mode=TwoWay}" TabIndex="23" Margin="0,2,0,2" VerticalAlignment="Center" />
						<Button Grid.Row="2" Grid.Column="2" Content="..." TabIndex="24" Command="{Binding OutputBrowseCommand}" Padding="5,2,5,2" Margin="5,2,0,2" HorizontalAlignment="Left" VerticalAlignment="Center" />
						
						<!-- Generate .css -->
						<TextBlock Grid.Row="3" Grid.Column="0" Text="Build css" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
						<CheckBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" TabIndex="25" IsChecked="{Binding EnableCss, Mode=TwoWay}" Margin="0,5,0,5" />
						
						<!-- Build sample html -->
						<TextBlock Grid.Row="4" Grid.Column="0" Text="Build html" Foreground="White" Margin="0,0,4,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
						<CheckBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" TabIndex="26" IsChecked="{Binding BuildSampleHtml, Mode=TwoWay}" Margin="0,5,0,5" />
					</Grid>
				</StackPanel>
			</Border>

			<!-- Buttons -->
			<Border Background="#595959" CornerRadius="3" Margin="0,0,0,2">
				<StackPanel Margin="4" Orientation="Horizontal">
					<Button Content="Generate sprite" Command="{Binding GenerateSpriteCommand}" BorderThickness="2" TabIndex="40" Padding="7,4,7,4" HorizontalAlignment="Left" Margin="0,0,4,0" VerticalAlignment="Center" Cursor="Hand" />
					<Button Content="Load .xml" Command="{Binding LoadXmlCommand}" TabIndex="41" Padding="7,4,7,4" HorizontalAlignment="Left" Margin="0,0,4,0" VerticalAlignment="Center" Cursor="Hand" />
					<Button Content="Save .xml" Command="{Binding SaveXmlCommand}" TabIndex="42" Padding="7,4,7,4" HorizontalAlignment="Left" Margin="0,0,4,0" VerticalAlignment="Center" Cursor="Hand" />
				</StackPanel>
			</Border>

			<!-- Preview -->
			<Border Background="#595959" CornerRadius="3" Margin="0,0,0,2" Visibility="{Binding EnableCss, Converter={StaticResource VisibilityConverter}}">
				<StackPanel Margin="4">
					<TextBlock Text="Preview" Style="{DynamicResource HeaderTextStyle}" />
					<Border x:Name="Preview" ClipToBounds="True" Margin="0,2,0,0" CornerRadius="3">
						<avalon:TextEditor Name="textEditor" TabIndex="50" Background="#444444" Foreground="White" FontFamily="Consolas" FontSize="10pt" IsReadOnly="True" MinHeight="200" />
					</Border>
				</StackPanel>
			</Border>
			
		</StackPanel>
		
	</Grid>
</UserControl>
